package com.jyserver.common.AutoCode.jybaits.element.pc.From;

public class validator {

    public static String validID() {
        return " var validID = (rule, value, callback) => {\n" +
                "        if (value == '' || value == undefined) {\n" +
                "            callback()\n" +
                "        } else {\n" +
                "            let reg = /^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$/\n" +
                "            if (!reg.test(value)) {\n" +
                "                callback(new Error('身份证号码不正确'))\n" +
                "            }\n" +
                "        }\n" +
                "        callback();\n" +
                "    };\n";
    }

    public static String validphone() {
        return "var validphone = (rule, value, callback) => {\n" +
                "        if (value == '' || value == undefined) {\n" +
                "            callback()\n" +
                "        } else {\n" +
                "            let reg = /^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$/\n" +
                "            if (value.length == 11 && /^((13|14|15|17|18)[0-9]{1}\\d{8})$/.test(value)) {\n" +
                "            } else {\n" +
                "                callback(new Error('手机号码不正确'))\n" +
                "            }\n" +
                "        }\n" +
                "        callback();\n" +
                "    };\n";
    }

    public static String validInt() {
        return "var validInt= (rule, value, callback) => {\n" +
                "        if (value == '' || value == undefined) {\n" +
                "            callback()\n" +
                "        } else if(!(value % 1 === 0)) {\n" +
                "            callback(new Error('请输入整数'))\n" +
                "        }\n" +
                "        callback();\n" +
                "    };\n";
    }

    public static String validemail() {
        return " var validemail = (rule, value, callback) => {\n" +
                "        if (value == '' || value == undefined) {\n" +
                "            callback()\n" +
                "        } else {\n" +
                "            let mailReg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/\n" +
                "            if (mailReg.test(value)) {\n" +
                "                callback();\n" +
                "            } else {\n" +
                "                callback(new Error('邮箱不正确'))\n" +
                "            }\n" +
                "        }\n" +
                "        callback();\n" +
                "    };\n";
    }


}
